<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ page import="performReservation.SMMDBBean"%>
<%@ page import="java.sql.*"%>
<%!
	String email =null;
	String passwd = null;
	Cookie cookie = null;
%>
<% request.setCharacterEncoding("euc-kr");%>

<jsp:useBean id="manager" scope="page" class="performReservation.Admin"/>



<%
	email = request.getParameter("email");
	passwd = request.getParameter("password");
	manager.setEmail(email);manager.setPasswd(passwd);
	SMMDBBean mProcess = SMMDBBean.getInstance();
	int i = mProcess.login(manager);
	if(i==1){
		cookie = new Cookie("email",email);
		cookie.setMaxAge(60*30);
		cookie.setPath("/");
		response.addCookie(cookie);
		cookie = new Cookie("pwd",passwd);
		cookie.setMaxAge(60*30);
		cookie.setPath("/");
		response.addCookie(cookie);
		cookie = new Cookie("type","admin");
		cookie.setMaxAge(60*30);
		cookie.setPath("/");
		response.addCookie(cookie);
		%>
		<jsp:forward page="index.jsp"/>
		<%
	}else if(i==2){
		cookie = new Cookie("email",email);
		cookie.setMaxAge(60*30);
		cookie.setPath("/");
		response.addCookie(cookie);
		cookie = new Cookie("pwd",passwd);
		cookie.setMaxAge(60*30);
		cookie.setPath("/");
		response.addCookie(cookie);
		cookie = new Cookie("type","cus");
		cookie.setMaxAge(60*30);
		cookie.setPath("/");
		response.addCookie(cookie);
		%>
		<jsp:forward page="index.jsp"/>
		<%
	}else{
		response.setHeader("Error Occurs","");
	out.println("Invalid Email or password.Please try again !!");
	}
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
</head>
<body>
	
</body>
</html>